package com.example.tourpal.model;

import java.io.File;
import java.io.Serializable;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;

public class User implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int id;
	private int headRes=0;
	private String head;
	private String email;
	private String phone;
	private String userName;
	private int sex;
	private String password;
	private String accessToken;
	
	public User(String email, String phone, String userName, int sex,
			String password) {
		super();
		this.email = email;
		this.phone = phone;
		this.userName = userName;
		this.sex = sex;
		this.password = password;
	}

	public User(int id, String email, String userName, int sex, String password) {
		super();
		this.id = id;
		this.email = email;
		this.userName = userName;
		this.sex = sex;
		this.password = password;
	}

	public static User getDefaultUser() {
		User user = new User(1, "test", "test", 1, "test");
		return user;
	}

	public String getAccessToken() {
		return accessToken;
	}

	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	public int getHeadRes() {
		return this.headRes;
	}

	public void setHeadRes(int headRes) {
		this.headRes = headRes;
	}
	
	public Bitmap getHead() {
		String headPath = Environment.getExternalStorageDirectory() + "/TourPal/."
				+ this.userName + ".png";
		File headFile = new File(headPath);
		if (headFile.exists()) {
			setHead(headPath);
		}
		return BitmapFactory.decodeFile(headPath);
	}

	public void setHead(String head) {
		this.head = head;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", head=" + head + ", email=" + email
				+ ", phone=" + phone + ", userName=" + userName + ", sex="
				+ sex + ", password=" + password + ", accessToken="
				+ accessToken + "]";
	}

}
